package com.iaiai.cobra.core.config;

import com.iaiai.cobra.core.config.intercepter.LogIntercepter;
import com.iaiai.cobra.core.config.intercepter.LoginIntercepter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
class ApplicationConfig implements WebMvcConfigurer {

    @Autowired
    private LogIntercepter logIntercepter;  //日志用

    @Autowired
    private LoginIntercepter loginIntercepter;  //登录

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(logIntercepter).addPathPatterns("/**");
        registry.addInterceptor(loginIntercepter)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/login.do");
    }

}
